function initCity(){
	let ajax=new AjaxUtil();
	let url="nativePlace.servlet?code="+document.getElementById("selProvince").value;
	ajax.get(url,(xhr)=>{
		let json=JSON.parse(xhr.responseText);
		let node=document.getElementById("selCity");
		node.innerHTML="";
		if(json.msg!="no date"){
			let defaultOption=document.createElement("option");
			defaultOption.value="0000";
			defaultOption.innerHTML="请选择城市";
			defaultOption.selected=true;
			node.appendChild(defaultOption);
			json.result.forEach((item)=>{
				let option=document.createElement("option");
				option.value=item.code;
				option.innerHTML=item.name;
				node.appendChild(option);
			});
		}		
	});
	
//	let xhr=new XMLHttpRequest();
//	let url="nativePlace.servlet?code="+document.getElementById("selProvince").value;
//	xhr.open("GET",url,true);
//	xhr.addEventListener("readystatechange",()=>{
//		if(xhr.readyState==4 && xhr.status==200){
//			let json=JSON.parse(xhr.responseText);
//			let node=document.getElementById("selCity");
//			node.innerHTML="";
//			if(json.msg!="no date"){
//				let defaultOption=document.createElement("option");
//				defaultOption.value="0000";
//				defaultOption.innerHTML="请选择城市";
//				defaultOption.selected=true;
//				node.appendChild(defaultOption);
//				json.result.forEach((item)=>{
//					let option=document.createElement("option");
//					option.value=item.code;
//					option.innerHTML=item.name;
//					node.appendChild(option);
//				});
//			}
//		}
//	},false);
//	xhr.send(null);
}
function passwordcheck(){
	document.getElementById("password").addEventListener("focus",()=>{
	    document.querySelector("#passwordMessage").innerHTML="";
	    document.querySelector("#passwordImage").classList.remove("errorImg");
	    document.querySelector("#passwordMessage").classList.remove("errorMessage");
	    document.querySelector("#passwordMessage").classList.remove("okMessage");
	    document.querySelector("#passwordImage").classList.remove("okImg");
	},false);
	document.getElementById("password").addEventListener("blur",()=>{
	    let regExp= /^\w{8,20}$/;
	    if(!regExp.test(document.getElementById("password").value)){
	        document.querySelector("#passwordMessage").innerHTML="密码格式不正确！";
	        document.querySelector("#passwordMessage").classList.add("errorMessage");
	        document.querySelector("#passwordImage").classList.add("errorImg");
	    }else{
	        document.querySelector("#passwordMessage").innerHTML="密码格式符合要求！";
	        document.querySelector("#passwordMessage").classList.add("okMessage");
	        document.querySelector("#passwordImage").classList.add("okImg"); 
	    }
	},false); 
	document.getElementById("rePassword").addEventListener("focus",()=>{
	    document.querySelector("#rePasswordImage").innerHTML="";
	    document.querySelector("#rePasswordImage").classList.remove("errorImg");
	    document.querySelector("#rePasswordMessage").classList.remove("errorMessage");
	    document.querySelector("#rePasswordMessage").classList.remove("okMessage");
	    document.querySelector("#rePasswordImage").classList.remove("okImg");
	},false);
	document.getElementById("rePassword").addEventListener("blur",()=>{
	    console.log(document.getElementById("password").value);
	    console.log(document.getElementById("rePassword").value);
	        if(document.getElementById("password").value!=document.getElementById("rePassword").value){
	        document.querySelector("#rePasswordMessage").innerHTML="与原密码不同";
	        document.querySelector("#rePasswordMessage").classList.add("errorMessage");
	        document.querySelector("#rePasswordImage").classList.add("errorImg");
	    }else{
	    document.querySelector("#rePasswordMessage").innerHTML="密码相同";
	    document.querySelector("#rePasswordMessage").classList.add("okMessage");
	    document.querySelector("#rePasswordImage").classList.add("okImg"); 
	    }
	},false); 
}
function init(){
	document.getElementById("selProvince").addEventListener("change",initCity,false);
	passwordcheck();
}
window.addEventListener("load",init,false);